<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# OPTIONS_GHC -optc-DWINVER=0x0600 #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# OPTIONS_GHC -optc-D_WIN32_WINNT=0x0600 #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\Graphics\\Win32\\GDI\\Clip.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LINE 2 &quot;libraries\\Win32\\Graphics\\Win32\\GDI\\Clip.hsc&quot; #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LINE 6 &quot;libraries\\Win32\\Graphics\\Win32\\GDI\\Clip.hsc&quot; #-}</span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  Graphics.Win32.GDI.Clip</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) Alastair Reid, 1997-2003</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  Esa Ilari Vuokko &lt;ei@vuokko.info&gt;</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- A collection of FFI declarations for interfacing with Win32.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Clip</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad</span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.Message</span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">WindowMessage</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign</span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">UINT</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-identifier">cF_BITMAP</span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-41"></span><span class="hs-identifier">cF_BITMAP</span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-42"></span><span class="hs-identifier">cF_DIB</span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-43"></span><span class="hs-identifier">cF_DIB</span><span>                </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-44"></span><span class="hs-identifier">cF_DIF</span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-45"></span><span class="hs-identifier">cF_DIF</span><span>                </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">5</span><span>
</span><span id="line-46"></span><span class="hs-identifier">cF_DSPBITMAP</span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-47"></span><span class="hs-identifier">cF_DSPBITMAP</span><span>          </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">130</span><span>
</span><span id="line-48"></span><span class="hs-identifier">cF_DSPENHMETAFILE</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-49"></span><span class="hs-identifier">cF_DSPENHMETAFILE</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">142</span><span>
</span><span id="line-50"></span><span class="hs-identifier">cF_DSPMETAFILEPICT</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-51"></span><span class="hs-identifier">cF_DSPMETAFILEPICT</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">131</span><span>
</span><span id="line-52"></span><span class="hs-identifier">cF_DSPTEXT</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-53"></span><span class="hs-identifier">cF_DSPTEXT</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">129</span><span>
</span><span id="line-54"></span><span class="hs-identifier">cF_ENHMETAFILE</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-55"></span><span class="hs-identifier">cF_ENHMETAFILE</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">14</span><span>
</span><span id="line-56"></span><span class="hs-identifier">cF_GDIOBJFIRST</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-57"></span><span class="hs-identifier">cF_GDIOBJFIRST</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">768</span><span>
</span><span id="line-58"></span><span class="hs-identifier">cF_HDROP</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-59"></span><span class="hs-identifier">cF_HDROP</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">15</span><span>
</span><span id="line-60"></span><span class="hs-identifier">cF_LOCALE</span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-61"></span><span class="hs-identifier">cF_LOCALE</span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16</span><span>
</span><span id="line-62"></span><span class="hs-identifier">cF_METAFILEPICT</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-63"></span><span class="hs-identifier">cF_METAFILEPICT</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">3</span><span>
</span><span id="line-64"></span><span class="hs-identifier">cF_OEMTEXT</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-65"></span><span class="hs-identifier">cF_OEMTEXT</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">7</span><span>
</span><span id="line-66"></span><span class="hs-identifier">cF_OWNERDISPLAY</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-67"></span><span class="hs-identifier">cF_OWNERDISPLAY</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">128</span><span>
</span><span id="line-68"></span><span class="hs-identifier">cF_PALETTE</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-69"></span><span class="hs-identifier">cF_PALETTE</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">9</span><span>
</span><span id="line-70"></span><span class="hs-identifier">cF_PENDATA</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-71"></span><span class="hs-identifier">cF_PENDATA</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">10</span><span>
</span><span id="line-72"></span><span class="hs-identifier">cF_PRIVATEFIRST</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-73"></span><span class="hs-identifier">cF_PRIVATEFIRST</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">512</span><span>
</span><span id="line-74"></span><span class="hs-identifier">cF_PRIVATELAST</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-75"></span><span class="hs-identifier">cF_PRIVATELAST</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">767</span><span>
</span><span id="line-76"></span><span class="hs-identifier">cF_RIFF</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-77"></span><span class="hs-identifier">cF_RIFF</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">11</span><span>
</span><span id="line-78"></span><span class="hs-identifier">cF_SYLK</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-79"></span><span class="hs-identifier">cF_SYLK</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4</span><span>
</span><span id="line-80"></span><span class="hs-identifier">cF_TEXT</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-81"></span><span class="hs-identifier">cF_TEXT</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-82"></span><span class="hs-identifier">cF_WAVE</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-83"></span><span class="hs-identifier">cF_WAVE</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">12</span><span>
</span><span id="line-84"></span><span class="hs-identifier">cF_TIFF</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-85"></span><span class="hs-identifier">cF_TIFF</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">6</span><span>
</span><span id="line-86"></span><span class="hs-identifier">cF_DIBV5</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-87"></span><span class="hs-identifier">cF_DIBV5</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">17</span><span>
</span><span id="line-88"></span><span class="hs-identifier">cF_GDIOBJLAST</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-89"></span><span class="hs-identifier">cF_GDIOBJLAST</span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1023</span><span>
</span><span id="line-90"></span><span class="hs-identifier">cF_UNICODETEXT</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-91"></span><span class="hs-identifier">cF_UNICODETEXT</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">13</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-pragma">{-# LINE 68 &quot;libraries\\Win32\\Graphics\\Win32\\GDI\\Clip.hsc&quot; #-}</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-identifier">wM_CLIPBOARDUPDATE</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WindowMessage</span><span>
</span><span id="line-70"></span><span class="hs-identifier">wM_CLIPBOARDUPDATE</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">0x031D</span><span> </span><span class="hs-comment">-- #const WM_CLIPBOARDUPDATE -- Can't use constant due to GHC 7.8.x support.</span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-comment">-- % , CF_UNICODETEXT  -- WinNT only</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h ChangeClipboardChain&quot;</span><span>
</span><span id="line-75"></span><span>  </span><span class="hs-identifier">changeClipboardChain</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-identifier">closeClipboard</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span class="hs-identifier">closeClipboard</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-79"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;CloseClipboard&quot;</span><span> </span><span class="hs-identifier">c_CloseClipboard</span><span>
</span><span id="line-80"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h CloseClipboard&quot;</span><span>
</span><span id="line-81"></span><span>  </span><span class="hs-identifier">c_CloseClipboard</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-82"></span><span>
</span><span id="line-83"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h CountClipboardFormats&quot;</span><span>
</span><span id="line-84"></span><span>  </span><span class="hs-identifier">countClipboardFormats</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-identifier">emptyClipboard</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span class="hs-identifier">emptyClipboard</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-88"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;EmptyClipboard&quot;</span><span> </span><span class="hs-identifier">c_EmptyClipboard</span><span>
</span><span id="line-89"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h EmptyClipboard&quot;</span><span>
</span><span id="line-90"></span><span>  </span><span class="hs-identifier">c_EmptyClipboard</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="hs-comment">-- original also tested GetLastError() != NO_ERROR</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-identifier">enumClipboardFormats</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-95"></span><span class="hs-identifier">enumClipboardFormats</span><span> </span><span class="hs-identifier">format</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-96"></span><span>  </span><span class="hs-identifier">format'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_EnumClipboardFormats</span><span> </span><span class="hs-identifier">format</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-identifier">when</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">format'</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-98"></span><span>    </span><span class="hs-identifier">failUnlessSuccess</span><span> </span><span class="hs-string">&quot;EnumClipboardFormats&quot;</span><span> </span><span class="hs-identifier">getLastError</span><span>
</span><span id="line-99"></span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">format'</span><span>
</span><span id="line-100"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h EnumClipboardFormats&quot;</span><span>
</span><span id="line-101"></span><span>  </span><span class="hs-identifier">c_EnumClipboardFormats</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-102"></span><span>
</span><span id="line-103"></span><span class="hs-identifier">getClipboardData</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HANDLE</span><span>
</span><span id="line-104"></span><span class="hs-identifier">getClipboardData</span><span> </span><span class="hs-identifier">format</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-105"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetClipboardData&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetClipboardData</span><span> </span><span class="hs-identifier">format</span><span>
</span><span id="line-106"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetClipboardData&quot;</span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-identifier">c_GetClipboardData</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HANDLE</span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-identifier">getClipboardFormatName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-110"></span><span class="hs-identifier">getClipboardFormatName</span><span> </span><span class="hs-identifier">format</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-111"></span><span>  </span><span class="hs-identifier">allocaArray</span><span> </span><span class="hs-number">256</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-112"></span><span>  </span><span class="hs-identifier">len</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIfZero</span><span> </span><span class="hs-string">&quot;GetClipboardFormatName&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-113"></span><span>    </span><span class="hs-identifier">c_GetClipboardFormatName</span><span> </span><span class="hs-identifier">format</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-number">256</span><span>
</span><span id="line-114"></span><span>  </span><span class="hs-identifier">peekTStringLen</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_name</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-115"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetClipboardFormatNameW&quot;</span><span>
</span><span id="line-116"></span><span>  </span><span class="hs-identifier">c_GetClipboardFormatName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-117"></span><span>
</span><span id="line-118"></span><span class="hs-identifier">getClipboardOwner</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-119"></span><span class="hs-identifier">getClipboardOwner</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-120"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetClipboardOwner&quot;</span><span> </span><span class="hs-identifier">c_GetClipboardOwner</span><span>
</span><span id="line-121"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetClipboardOwner&quot;</span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-identifier">c_GetClipboardOwner</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="hs-identifier">getClipboardViewer</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-125"></span><span class="hs-identifier">getClipboardViewer</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetClipboardViewer&quot;</span><span> </span><span class="hs-identifier">c_GetClipboardViewer</span><span>
</span><span id="line-127"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetClipboardViewer&quot;</span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-identifier">c_GetClipboardViewer</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="hs-identifier">getOpenClipboardWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-131"></span><span class="hs-identifier">getOpenClipboardWindow</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-132"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetClipboardWindow&quot;</span><span> </span><span class="hs-identifier">c_GetOpenClipboardWindow</span><span>
</span><span id="line-133"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetOpenClipboardWindow&quot;</span><span>
</span><span id="line-134"></span><span>  </span><span class="hs-identifier">c_GetOpenClipboardWindow</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span class="hs-identifier">getPriorityClipboardFormat</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">ClipboardFormat</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-137"></span><span class="hs-identifier">getPriorityClipboardFormat</span><span> </span><span class="hs-identifier">formats</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-138"></span><span>  </span><span class="hs-identifier">withArray</span><span> </span><span class="hs-identifier">formats</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">format_array</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-identifier">failIf</span><span> </span><span class="hs-special">(</span><span class="hs-operator">==</span><span> </span><span class="hs-glyph">-</span><span class="hs-number">1</span><span class="hs-special">)</span><span> </span><span class="hs-string">&quot;GetPriorityClipboardFormat&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-140"></span><span>    </span><span class="hs-identifier">c_GetPriorityClipboardFormat</span><span> </span><span class="hs-identifier">format_array</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">length</span><span> </span><span class="hs-identifier">formats</span><span class="hs-special">)</span><span>
</span><span id="line-141"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetPriorityClipboardFormat&quot;</span><span>
</span><span id="line-142"></span><span>  </span><span class="hs-identifier">c_GetPriorityClipboardFormat</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">UINT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h IsClipboardFormatAvailable&quot;</span><span>
</span><span id="line-145"></span><span>  </span><span class="hs-identifier">isClipboardFormatAvailable</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span class="hs-identifier">openClipboard</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span class="hs-identifier">openClipboard</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;OpenClipboard&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_OpenClipboard</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-150"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h OpenClipboard&quot;</span><span>
</span><span id="line-151"></span><span>  </span><span class="hs-identifier">c_OpenClipboard</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-identifier">registerClipboardFormat</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-154"></span><span class="hs-identifier">registerClipboardFormat</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-155"></span><span>  </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-156"></span><span>  </span><span class="hs-identifier">failIfZero</span><span> </span><span class="hs-string">&quot;RegisterClipboardFormat&quot;</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-157"></span><span>    </span><span class="hs-identifier">c_RegisterClipboardFormat</span><span> </span><span class="hs-identifier">c_name</span><span>
</span><span id="line-158"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h RegisterClipboardFormatW&quot;</span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-identifier">c_RegisterClipboardFormat</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-identifier">setClipboardData</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HANDLE</span><span>
</span><span id="line-162"></span><span class="hs-identifier">setClipboardData</span><span> </span><span class="hs-identifier">format</span><span> </span><span class="hs-identifier">mem</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;SetClipboardData&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetClipboardData</span><span> </span><span class="hs-identifier">format</span><span> </span><span class="hs-identifier">mem</span><span>
</span><span id="line-164"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetClipboardData&quot;</span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-identifier">c_SetClipboardData</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ClipboardFormat</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HANDLE</span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span class="hs-identifier">setClipboardViewer</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-168"></span><span class="hs-identifier">setClipboardViewer</span><span> </span><span class="hs-identifier">wnd</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-169"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;SetClipboardViewer&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetClipboardViewer</span><span> </span><span class="hs-identifier">wnd</span><span>
</span><span id="line-170"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetClipboardViewer&quot;</span><span>
</span><span id="line-171"></span><span>  </span><span class="hs-identifier">c_SetClipboardViewer</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-172"></span></pre></body></html>